home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / wfc007.000 / include / csvcmgr.hpp < prev    next >
C/C++ Source or Header  |  1996-04-08  |  2KB  |  80 lines

  1. #if ! defined( SERVICE_MANAGER_CLASS_HEADER )
  2.  
  3. /*
  4. ** Author: Samuel R. Blackburn
  5. ** CI$: 76300,326
  6. ** Internet: sammy@sed.csc.com
  7. **
  8. ** You can use it any way you like.
  9. */
  10.  
  11. #define SERVICE_MANAGER_CLASS_HEADER
  12.  
  13. class CServiceNameAndStatusA : public _ENUM_SERVICE_STATUSA
  14. {
  15.    public:
  16.  
  17.       CServiceNameAndStatusA();
  18.       virtual ~CServiceNameAndStatusA();
  19.       virtual void Copy( const _ENUM_SERVICE_STATUSA *source );
  20.       virtual void Empty( void );
  21. };
  22.  
  23. class CServiceNameAndStatusW : public _ENUM_SERVICE_STATUSW
  24. {
  25.    public:
  26.  
  27.       CServiceNameAndStatusW();
  28.       virtual ~CServiceNameAndStatusW();
  29.       virtual void Copy( const _ENUM_SERVICE_STATUSW *source );
  30.       virtual void Empty( void );
  31. };
  32.  
  33. #if defined( UNICODE )
  34. #define CServiceNameAndStatus CServiceNameAndStatusW
  35. #else
  36. #define CServiceNameAndStatus CServiceNameAndStatusA
  37. #endif // UNICODE
  38.  
  39. class CServiceControlManager : public CObject
  40. {
  41.    private:
  42.  
  43.       void m_Initialize( void );
  44.  
  45.    protected:
  46.  
  47.       SC_HANDLE m_ManagerHandle;
  48.  
  49.       ENUM_SERVICE_STATUS *m_Buffer;
  50.  
  51.       DWORD m_BufferSize;
  52.       DWORD m_CurrentEntryNumber;
  53.       DWORD m_ErrorCode;
  54.       DWORD m_NumberOfEntries;
  55.  
  56.       CString m_MachineName;
  57.  
  58.    public:
  59.  
  60.       CServiceControlManager();
  61.       virtual ~CServiceControlManager();
  62.  
  63.       virtual void  Close( void );
  64.       virtual BOOL  Continue( LPCTSTR service_name );
  65.       virtual BOOL  EnumerateStatus( DWORD state = SERVICE_ACTIVE,
  66.                                      DWORD type  = SERVICE_WIN32 );
  67.       virtual DWORD GetErrorCode( void ) const;
  68.       virtual BOOL  GetNext( CServiceNameAndStatus& status );
  69.       virtual BOOL  Install( LPCTSTR service_name, LPCTSTR friendly_name, LPCTSTR name_of_executable_file );
  70.       virtual BOOL  Open( DWORD   what_to_open  = SC_MANAGER_ALL_ACCESS,
  71.                           LPCTSTR database_name = NULL,
  72.                           LPCTSTR machine_name  = NULL );
  73.       virtual BOOL  Pause( LPCTSTR service_name );
  74.       virtual BOOL  Remove( LPCTSTR service_name );
  75.       virtual BOOL  Start( LPCTSTR service_name, DWORD service_argc = 0, LPCTSTR *service_argv = NULL );
  76.       virtual BOOL  Stop( LPCTSTR service_name );
  77. };
  78.  
  79. #endif // SERVICE_MANAGER_CLASS_HEADER
  80.